<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->title}</title>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/admin.css" rel="stylesheet" type="text/css" />
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/uploadify.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
th { text-align:right; }
td { text-align:left; }
.template { border:none; border-bottom:1px #999 solid; }
.color { color:#000000; cursor:pointer;}
-->
</style>
</head>
<body>
<div class="wrapper">
  <div class="title shadow titleBg">
    <table width="100%" border="0" cellspacing="1">
      <tr>
        <td><h1> {:$i->title} => {:if $i->p[0] eq "mod"}修改{:elseif $i->p[0] eq "add"}
            添加{:/if} </h1></td>
      </tr>
    </table>
  </div>
  <div class="content shadow">
    <form id="form1" method="post" action="{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/insert/0/{:$i->p[2]}/{:$i->p[3]}" target="autoFrame">
      <table width="100%" border="0" cellspacing="1">
        <tr>
          <th width="20%">公司名称：</th>
          <td width="80%"><input class="inputtitle showcolor" name="title" type="text" size="60" id="title" value="" />
            <input name="color" type="text" size="7" id="color" value="" class="color" />
            </td>
        </tr>
        <tr>
          <th width="20%">属　性：</th>
          <td width="80%"><input class='noBorder' type='checkbox' name='flag[]' id='flagsh' value='h'>
            <label for="flagsh"> 头条[h]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsc' value='c'>
            <label for="flagsc"> 推荐[c]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsp' value='p'>
            <label for="flagsp"> 图文[p]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsf' value='f'>
            <label for="flagsf"> 幻灯[f]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagss' value='s'>
            <label for="flagss"> 滚动[s]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsj' value='j'>
            <label for="flagsj"> 跳转[a]</label>
            <input class='noBorder' type='checkbox' name='flag[]' id='flagsb' value='b'>
            <label for="flagsb"> 加粗[b]</label></td>
        </tr>
        <tr class="j hidden">
          <th width="20%">跳转地址：</th>
          <td width="80%"><input name="redirectUrl" type="text" size="60" id="redirectUrl" value="" />
            *</td>
        </tr>
        <tr>
          <th>图　片：</th>
          <td><input title="点击查看图片" name="thumb" type="text" size="50" id="thumb" value="" />
            <a href='#' title="上传图片" class="buttonBox hidden" id="preView">预览</a> 
            <input type="file" name="uploadify" id="uploadify" size="2" />
            <div id="fileQueue"></div></td>
        </tr>
        <tr>
          <th>栏　目：</th>
          <td><select name="categoryId" id="categoryId" onchange="if(!this.value){alert('请选择白色背景的栏目');this.value = 0;return false;}">
              <option value="0">--请选择栏目--</option>
              {:foreach item=item from=$i->category}
              <option {:if $item->channelId != $i->channelId}style="background:#ccc;" value="-1"{:else}value="{:$item->id}"{:/if} {:if $item->id == $i->categoryId}selected="selected"{:/if}>{:$item->name}</option>
              {:/foreach}
              </select>
            *</td>
        </tr>
        {:field fields=$i->addFields}
        <tr class="notJ">
          <th width="20%">{:$name}：</th>
          <td width="80%"> {:$code} </td>
        </tr>
        {:/field}
          <tr class="notJ">
            <th width="20%">公司简介：</th>
            <td width="80%"><textarea name="desc" cols="58" rows="8" id="desc"></textarea></td>
          </tr>
        <tr class="notJ" id="advShow">
          <th width="20%">&nbsp;</th>
          <td width="80%">【<a href="#" onclick="$('#advItems').show();$('#advHide').show();$('#advShow').hide();return false;">显示高级选项</a>】</td>
        </tr>
        <tr class="notJ hidden" id="advHide">
          <th width="20%">&nbsp;</th>
          <td width="80%">【<a href="#" onclick="$('#advShow').show();$('#advHide').hide();$('#advItems').hide();return false;">隐藏高级选项</a>】</td>
        </tr>
        <tbody class="notJ hidden" id="advItems">
          <tr>
            <th width="20%">关键词：</th>
            <td width="80%"><input name="keywords" type="text" size="50" id="keywords" value="" />
              (多个时用空格隔开)</td>
          </tr>
          <tr>
            <th>文档排序：</th>
            <td><select name="ordering" id="ordering">
                <option value="0" selected="selected">默认排序</option>
                <option value="7">置顶一周</option>
                <option value="15">置顶半个月</option>
                <option value="30">置顶一个月</option>
                <option value="90">置顶三个月</option>
                <option value="180">置顶半年</option>
                <option value="360">置顶一年</option>
              </select></td>
          </tr>
          <tr>
            <th>列表显示：</th>
            <td><label>
                <input class="noBorder" name="listed" type="radio" value="1" checked="checked" />
                是</label>
              <label>
                <input name="listed" class="noBorder" type="radio" value="0" />
                否</label>
              (如果选否则不会在首页和列表页中出现)</td>
          </tr>
          <tr>
            <th>访问控制：</th>
            <td>
              <select name="visit" id="visit">
                <option value="0" selected="selected">允许访问</option>
                <option value="1">禁止访问</option>
              </select>
            </td>
          </tr>
          <tr>
            <th width="20%">发布日期：</th>
            <td width="80%"><input name="pubTime" type="text" size="20" id="pubTime" value="{:$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
" /></td>
          </tr>
          <tr>
            <th width="20%">文档模板：</th>
            <td width="80%">{:$smarty.const.ROOT_PATH}{:$i->Load->var.templatePath}/
              <input name="templateName" type="text" size="30" value="" id="templateName" class="inputLine" /></td>
          </tr>
          <tr>
            <th width="20%" nowrap="nowrap">生成文档：</th>
            <td width="80%">{:$smarty.const.ROOT_PATH}
              <input name="fileName" type="text" size="30" value="" id="fileName" class="inputLine" />
              </td>
          </tr>
        </tbody>
        <tr>
          <th>&nbsp;</th>
          <td><input type="submit" id="submit" value=" 提 交 " />
            &nbsp;
            <input type="reset" onclick="history.go(-1);" value=" 返 回 " /></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/tooltip.css" rel="stylesheet" type="text/css" />
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/ui.all.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.core.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.draggable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.resizable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.dialog.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/common.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.tooltip.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.upload.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.colorpicker.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/swfobject.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.uploadify.v2.1.0.min.js"></script>
<script language="javascript" type="text/javascript">

function upload(url)
{
	$("#thumb").val(url);
	$("#preView").show();
}

function uploaded(e,queueId,fileObj,response,data)
{
	var error = $(response).find("#error").html();
	if(error != '')
	{
		alert(error);
	}
	else
	{
		$("#preView").show();
		var file = $(response).find("#file").html();
		$("#thumb").val(file);
	}
}

$(document).ready(function(){
	$("#uploadify").uploadify({
		'uploader'       : '{:$smarty.const.PUBLIC_DIR}/common/image/uploadify.swf',
		'script'         : '{:$smarty.const.BOOT_URL}/file/upload',
		'cancelImg'      : '{:$smarty.const.PUBLIC_DIR}/common/image/cancel.png',
		'queueID'        : 'fileQueue',
		'auto'           : true,
		'multi'          : false,
		'onComplete'     : function(e,queueId,fileObj,response,data){uploaded(e,queueId,fileObj,response,data);},
		'buttonImg'      : '{:$smarty.const.PUBLIC_DIR}/common/image/uploadButton.gif',
		'width'          : 90,
		'height'         : 13
	});
	
						   
	if($("#thumb").val() != "")
	{
		$("#preView").show();	
	}
	
	$("#categoryId").change(function(){
		if(this.value == -1)
		{
			alert('不能选择灰色背景的栏目');
			this.value = 0;
			return false;
		}
	});
	
	$("#preView").click(function(){
								   
		if($('.ui-dialog').length > 0)
		{
			$('.ui-dialog').remove();
		}
		
		if($('.ui-dialog-message').length > 0)
		{
			$('.ui-dialog-message').remove();
		}	
		
		var thumbValue = $("#thumb").val();
		if(thumbValue != "")
		{
			$('<div class="ui-dialog-message"><img src="' + thumbValue + '" onload="if(this.width > 350)this.width = 350;" /></div>').dialog({
				title:'图片预览',
				resizable : false,
				width : 380
			});
		}
	});
			
	$('form').submit(function(){
		postDialog();
	});
	
	$("#flagsj").click(
		function () {
			if(this.checked){
				$(".j").show();
				$(".notJ").hide();
			}else{
				$(".j").hide();
				$(".notJ").show();			
			}
		}
	);
	
	$("#color").colorpicker(); 
	
	$("#flagsb").click(
		function () {
			if(this.checked){
				$("#title").css("font-weight","bold");
			}else{
				$("#title").css("font-weight","normal");	
			}
		}
	);
	
});
</script>
</body>
</html>